home *** CD-ROM | disk | FTP | other *** search
/ Nebula 1 / Nebula One.iso / Utilities / Converters / Convert_MacPaint / Source / shared.subproj / TextConverter.m < prev    next >
Text File  |  1995-06-12  |  4KB  |  87 lines

  1. /***********************************************************************\
  2. Common class for subclassing text converters in all Convert programs
  3. Copyright (C) 1993 David John Burrowes
  4.  
  5. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 1, or (at your option) any later version.
  6.  
  7. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
  8.  
  9. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  10.  
  11. The author, David John Burrowes, can be reached at:
  12.     davidjohn@kira.net.netcom.com
  13.     David John Burrowes
  14.     1926 Ivy #10
  15.     San Mateo, CA 94403-1367
  16. \***********************************************************************/
  17.  
  18. /*====================================================================
  19. This is the implementation file for the TextConverter class.  Full documentation for this class can be found in the TextConverter.rtf file.  I will not duplicate all that fine information here.
  20.  
  21. NOTE: You may find that text doesn't line up properly unless you use the New Century Schoolbook Roman typeface, since this was created with it.
  22.  
  23. INFORMATION:
  24.     This is $Revision: 1.2 $ of this file
  25.     It was last modified by $Author: death $ on $Date: 93/04/04 23:45:22 $
  26.      $Log:    TextConverter.m,v $
  27. Revision 1.2  93/04/04  23:45:22  death
  28. Sun Apr  4 23:45:22 PDT 1993
  29.  
  30. Revision 1.1  93/01/10  15:08:51  death
  31. Sun Jan 10 15:08:51 PST 1993
  32.  
  33. ====================================================================*/
  34.  
  35. #import "TextConverter.h"
  36. #import <string.h>    // for memcpy
  37.  
  38. @implementation TextConverter
  39.  
  40. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  41. //    Routine:        ConvertCharacter:
  42. //    Parameters:    a character to be converted
  43. //    Returns:        the converted character
  44. //    Stores:        the character that we are returning.
  45. //    Description:
  46. //        This merely returns the chracter that we were passed, thus providing the
  47. //        trivial text conversion algorithm (everything maps to itself)
  48. //    Bugs:
  49. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  50. - (Character) ConvertCharacter: (Character) theCharacter
  51. {
  52.     [self ResetResults];
  53.     [self    StoreErrorCode: errOK AndText: "Of course nothing went wrong!"];
  54.     [self StoreCharacter: theCharacter];
  55.     return theCharacter;
  56. }
  57.  
  58.  
  59. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  60. //    Routine:        ConvertString:WithLength:
  61. //    Parameters:    a pointer to a string of data to be converted
  62. //                the length of the data the poiner poins to.
  63. //    Returns:        a poiner to a new block of data to be converted
  64. //    Stores:        the pointer we are returning
  65. //                the length of the new data
  66. //    Description:
  67. //        This converts the text in the source data area into a new area.
  68. //        As with ConvertCharacter:, this really just returns to the caller exactly what
  69. //        it passed us.
  70. //    Bugs:
  71. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  72. - (Pointer) ConvertString: (Pointer) theData WithLength: (Integer) length
  73. {
  74.     Pointer    newData;
  75.     [self    ResetResults];
  76.     
  77.     newData = NewPointer(length);
  78.     memcpy(newData, theData, length);
  79.     [self    StoreErrorCode: errOK AndText: "Of course nothing went wrong!"];
  80.     [self StorePointer: theData];
  81.     [self    PutPositiveInteger: length  Into: SECOND_RESULT];
  82.     
  83.     return theData;
  84.  
  85. }
  86. @end
  87.